import { BaseMod } from "../../base/BaseMod";
import { KeyCode } from "cc";
import { mapMod } from "../map/MapMod";
import { MsgId, MsgVo } from "../../cfg/Msg";

/**
 * 玩家模块
 */
export const playerMod = _ as PlayerMod;
export class PlayerMod extends BaseMod {

    pid: number
    name: string
    keys: KeyCode[] = [];

    onInit(): void {
        (playerMod as any) = this;
    }

    onJoin(data: MsgVo.login.JoinData) {
        this.pid = data.player.pid;
        this.name = data.player.name;
        mapMod.enterMap(data.player.mapId);
    }

    syncPlayer(x: number, y: number) {
        this.sendMsg(MsgId.syncPlayer, { x, y });
    }

}